<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/WEB-INF/tld/jmesa.tld" prefix="jmesa" %> 
<%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><strong>合同信息</strong></title>
<link href="/estate/css/css.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="/estate/js/jquery-1.2.2.pack.js"></script>
    <script type="text/javascript" src="/estate/js/jquery-1.3.min.js"></script> 
    <script type="text/javascript" src="/estate/js/jquery.jmesa.js"></script>
    <script type="text/javascript" src="/estate/js/jmesa.js"></script>              
    <link rel="stylesheet" type="text/css" href="/estate/css/jmesa.css"></link>
    <link rel="stylesheet" type="text/css" href="/estate/css/css.css"></link>
	<script type="text/javascript">
	function showlightbox(ShowUrl)
	{
		document.getElementById('lightbox-content').style.display='block';
		document.getElementById('lightbox-bg').style.display='block';
		if(ShowUrl!='')
		{
		document.getElementById('lightbox-iframe').src=ShowUrl;
		}
	}
	function closelightbox()
	{
		document.getElementById('lightbox-content').style.display='none';
		document.getElementById('lightbox-bg').style.display='none';
		document.getElementById('lightbox-iframe').src='about:blank';
	}
    	function selectAllItens() {
    		tid="contract_table";
		    var table = document.getElementById(tid);
		    var inputs = table.getElementsByTagName("input");
		    var inputOption = inputs[0];
		    var selectOrNot = false;
		    for (var i = 1; i < inputs.length; i++){
		    	if(i == 1 && inputOption.checked == true){
		    		selectOrNot = true;
		    	}else if(i == 1 && inputOption.checked == false){
		    		selectOrNot = false;
		    	}
		    	inputOption.checked = selectOrNot;
		        inputs[i].checked = inputOption.checked;
		    }

		} 
		function enterMultiType(form){
			form.action="/estate/admin/contractAction.action?method=list&multiType=true";

   			form.submit();
		}
		function enterSingleType(form){
			form.action="/estate/admin/contractAction.action?method=list&multiType=false";

   			form.submit();
		}
		
		function multiDel()  {
		
		question=confirm("确定批量删除合同？");
		if(question!=0){
		var cbArray = document.getElementsByName("cbMulti");
			var delStr = "";
			for(var i = 0;i<cbArray.length;i++){
    			if(cbArray[i].checked){
    				delStr = delStr+cbArray[i].value+",";
    			}
    		}
			window.location.href="/estate/admin/multiOperationInContractAction.action?currentPage=conList&operationType=multidel&deleStr="+delStr;
		}
	    }
	    function deleteConfirm(id){
	    question=confirm("删除合同将同时删除相关的文件，确定删除此合同？")
	    if(question!=0){
	    	window.location.href="/estate/admin/contractAction.action?method=delete&id="+id;
	    }
	    }
    </script>
    <style>
		#lightbox-content{position:absolute;height:420px;width:820px;margin:-250px 0px 0px -250px;top: 50%;left: 30%;text-align: center;background-color: #FFF;border: 1px solid #000;display:none;z-index:100;overflow:hidden;padding:10px 10px 40px 10px;}
		#lightbox-content p{ margin-top:8px;}
		#lightbox-bg{position:absolute;top:0;left:0;z-index: 90;background:#000;display:none;width:100%;height:100%;_height:2000px;filter:alpha(opacity=70);-moz-opacity:0.6;opacity:0.6;}
	</style>
</head>
<body>

<form  id="contractForm"  name="contractForm" action="/estate/admin/contractAction.action?method=list" method="post">
<table border="0" cellpadding="0" cellspacing="0" style="background-image:url(/estate/images/gtbg.gif) " width="100%">
    <tr>
      <td width="50%" height="82" rowspan="2"><img src="/estate/images/guide_01.gif"></td>
      <td width="50%" style="background-image:url(/estate/images/guide_02.gif);color:#cc1212; font-size:16px; font-weight:bold; text-align:right; padding-right:50px; letter-spacing:1px; " height="39"><strong>所有合同</strong></td>
    </tr>
     <tr><td width="50%" style="background-image:url(/estate/images/guide_03.gif); height:43px;" align="center" valign="middle">
	  <table width="50%" border="0" cellspacing="0" cellpadding="0">
        <tr align="center">
          <c:if test="${multiType != null}">
          	<c:if test="${multiType}">
          		<td><input name="Submit1" type="button" onclick="enterSingleType(contractForm)" onFocus="this.blur();" class="button4" value="单选模式" > </td>
          		<td><input name="Submit1" type="button" onclick="multiDel()" onFocus="this.blur();" class="button4" value="批量删除"> </td>
          	</c:if>
          </c:if>
          <c:if test="${!multiType}">
          <td><input name="Submit1" type="button" onclick="enterMultiType(contractForm)" onFocus="this.blur();" class="button4" value="批量模式"> </td>
          </c:if>
        </tr>
      </table></td>
    </tr>
</table><br>
<div align="center" >
	<div class="main" align="center" style="width:100%;height:400px;">
      <jmesa:struts2TableModel items="${contractList}" id="contract_table" var="bean" stateAttr="restore" editable="true" exportTypes="excel"  toolbar="com.estate.utils.JmesaToolBarPage" >
          <jmesa:htmlTable width="100%" style="text-align:center;" caption="<div style='height:20px;text-align:center;'>合同信息列表</div>">
              <jmesa:htmlRow uniqueProperty="id">
              	  <c:if test="${multiType != null}">
              	  	<c:if test="${multiType}">
	              	  	<jmesa:htmlColumn editable="false" sortable="false" property="chkbox" title="<input type='checkbox' onclick='selectAllItens()'>全选/全不选</input>"><input type="checkbox" id="cbMulti" name="cbMulti" value="${bean.id }"/></jmesa:htmlColumn>
              	  	</c:if>
              	  </c:if>
              	  <jmesa:htmlColumn property="number" sortable="true" title="合同编号"  editable="false"/>
                  <jmesa:htmlColumn property="name" editable="false" title="合同名称"/>
                  <jmesa:htmlColumn property="type" sortable="true" title="合同类型"  editable="false"/>
                  <jmesa:htmlColumn property="signState" editable="false" title="签订情况"/>
                  <jmesa:htmlColumn property="clientName" sortable="true" title="客户名称"  editable="false"/>
                  <jmesa:htmlColumn property="money" editable="false" title="合同金额(元)" />
                  <jmesa:htmlColumn property="signDate" sortable="true" title="签订日期"  editable="false"/>
                  <jmesa:htmlColumn property="createUser.name" sortable="true" title="创建人"  editable="false"/>
                  <jmesa:htmlColumn editable="false" title="操作">
                  <a href="/estate/admin/contractAction.action?method=detail&id=${bean.id }">浏览</a>&nbsp;&nbsp;
                  <a href="/estate/admin/contractAction.action?method=modify&id=${bean.id }">修改</a>&nbsp;&nbsp;
                  <a href="javascript:void(0)" onclick=deleteConfirm(${bean.id})>删除</a>
                  <a href="javascript:void(0)" onclick="showlightbox('contractAction.action?method=file&contractId=${bean.id}')">上传文件</a>
                  <a href="javascript:void(0)" onclick="showlightbox('contractFileAction.action?method=list&contractId=${bean.id}')">文件列表</a>
                  </jmesa:htmlColumn>
              </jmesa:htmlRow>
          </jmesa:htmlTable>
      </jmesa:struts2TableModel>
      </div>
</div>
<script type="text/javascript">
      function onInvokeAction(id){
          $.jmesa.setExportToLimit(id,'');
          $.jmesa.createHiddenInputFieldsForLimitAndSubmit(id);
      }  
      function onInvokeExportAction(id) {
			var parameterString = $.jmesa.createParameterStringForLimit(id);
			location.href = "testAction.action?method=export&" + parameterString;
      }

  </script>
  </form>
   <div id="lightbox-bg"></div>
	<div id="lightbox-content">
    <iframe id="lightbox-iframe" width="100%" frameborder="0" scrolling="no" src="about:blank" height="100%" ></iframe> 
     <p><a href="javascript:void(0)" onclick="closelightbox()">关闭</a></p> 
    </div>
</body>
</html>